package IHM;

import java.awt.Choice;
import java.awt.Container;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
/**
 * Classe initialisant la fenètre de génération de données
 * @author philippestepniewski
 */
public class genDataFrame
{

	private JFrame fenetre; 
	private JLabel nameFile;
	private JLabel setSize;
	private JLabel level;
	private JLabel dimension;
	
	private JTextField fileName; 
	private JTextField sizeSet;
	private JTextField dim;
	
	private Choice levelChoice;
	private JButton gen;
	private JButton quit; 

	private actionListener listener;
	/**
	 * Constructeur de la Fenetre principale.
	 */
	public genDataFrame(actionListener action){
		super();
		
		listener = action;
		
		build();
	}

	private void build()
	{
		fenetre = new JFrame("Data Generator");
		fenetre.setLocationRelativeTo(null);
		fenetre.setResizable(false);
		fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		nameFile = new JLabel("Nom du fichier : "); 
		fileName = new JTextField(20);
		fileName.setText("A remplir");
		
		setSize = new JLabel("Taille du jeux de donnees : ");
		sizeSet = new JTextField(5); 
		sizeSet.setText("5000");
		
		dimension = new JLabel("Dimension (image carre) : ");
		dim = new JTextField(3); 
		dim.setText("32");

		level = new JLabel("Difficulte");
		levelChoice = new Choice();
		levelChoice.add("1");
		levelChoice.add("2");
		levelChoice.add("3");
		
		gen = new JButton("Generer"); 

		quit = new JButton("Retour a la page principale");
		
	    gen.addActionListener(listener);
	    quit.addActionListener(listener); 

		Container conteneur = fenetre.getContentPane(); 
		GridLayout disposition = new GridLayout(5, 2); 

		conteneur.setLayout(disposition); 
		conteneur.add(nameFile); 
		conteneur.add(fileName); 
		conteneur.add(setSize); 
		conteneur.add(sizeSet);
		conteneur.add(dimension);
		conteneur.add(dim);
		conteneur.add(level);
		conteneur.add(levelChoice);
		conteneur.add(gen);
		conteneur.add(quit);
		
	    fenetre.pack(); 
	    fenetre.setVisible(true); 
	}
	
    public String size() {
        return sizeSet.getText(); 
    } 

    public String name() {
        return fileName.getText(); 
    } 

    public String level() {
        return levelChoice.getSelectedItem(); 
    }
    
    public String dim()
    {
    	return dim.getText();
    }
    
    public void close()
    {
    	fenetre.dispose();
    }
}
